package com.yeyks.controller.finance;

import com.yeyks.account.dal.domain.AccountInfo;
import com.yeyks.annotation.NeedToken;
import com.yeyks.common.ajax.AjaxResponseBody;
import com.yeyks.common.base.Arguments;
import com.yeyks.common.constants.AccountType;
import com.yeyks.commonReference.service.vip.MiniCardCommissionOverviewService;
import com.yeyks.vip.dal.domain.MiniCardCommissionOverview;
import com.yeyks.web.AccountUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 卖卡佣金账户相关接口
 *
 * @author shuai
 * @date 2020-01-07
 */
@Slf4j
@Api(tags = "卖卡佣金账户")
@RestController
@RequestMapping("/mini/card/account")
public class MiniCardSellAccountController {
    @Autowired
    private MiniCardCommissionOverviewService overviewService;

    @NeedToken
    @ApiOperation(value = "v4.1 --> 查询当前用户余额")
    @PostMapping("/detail")
    public AjaxResponseBody<MiniCardCommissionOverview> detail() {
        AccountInfo loginUser = AccountUtils.getLoginUser();
        Arguments.isTrue(AccountType.Administrator == loginUser.getType(), "你无权访问");
        MiniCardCommissionOverview overview = overviewService.getOverview(loginUser.getId(), loginUser.getType());
        return AjaxResponseBody.success(overview);
    }

}
